<?php
/**
 * Created by PhpStorm.
 * User: shkj
 * Date: 2020/4/18
 * Time: 22:01
 */

namespace app\api\controller\v1;


use think\facade\Request;
use app\api\service\Wechat;
use think\Loader;
class Admin extends Base
{
    private $obj;

    public function __construct() {
        $this->obj = model("Admin");

    }
    public function login(){
       $data = Request::post();

       $this->obj->login($data);
    }




    public function select(){
      
              $pagesize = Request::param('pagesize');
              $pagenum = Request::param('pagenum');
              
        $this->obj->select($pagesize,$pagenum);
    }


    public function add(){
        $data = Request::post();
     
        $validate = new \app\api\validate\Admin;
        if (!$validate->check($data)) {
            return_json(400,'失败',$validate->getError());
        }else{

            $this->obj->add($data);
        }
    }

    public function detail(){
        $id = Request::param('id');

        $this->obj->detail($id);
    }

    public function delete(){
        $id = Request::param('id');
       
        $this->obj->del($id);
    }

    public function edit(){
        $id = Request::param('id');
        $data = Request::post();
    
        $validate = new \app\api\validate\Admin;
        if (!$validate->check($data)) {
            return_json(400,'失败',$validate->getError());
        }else{

            $this->obj->edit($id,$data);
        }
    }

    public function status(){
        $data = Request::param();
        
        $this->obj->status($data);
    }

    public function delAll(){
          $ids = Request::param('ids');
       
          $this->obj->delAll($ids);
  
    }

}